<template>
    <div>
    <ul>
        <li v-for="(item, index) in items" :key="index">
            {{item.id}}-{{item.title}}-{{item.price}} -- 个数：{{item.count}}
        </li>
    </ul>
    总价格： {{allprice}}
    </div>
</template>
<script>
// mapState辅助取值，computed
import { mapState, mapActions } from 'vuex'
export default {
    name: 'cart',
    created() {
        // mutation
        this.$store.commit("cart/initprice")
    },
    data(){
        return {}
    },
    computed: {...mapState({items: state => state.cart.items, allprice: state => state.cart.allprice})}
}
</script>
